


//懒汉式单例又称惰性单例，前端不考虑，如果是后端可能会考虑高并发的情况下出现多个实例
class LazySingle {
	private static _instance = null;
	//限制产生多个对象
	private constructor(){

	}
	//获得实例对象
	public static getInstance():LazySingle{
		if(!this._instance){
			this._instance = new LazySingle();
		}
		return this._instance;
	}
}
//饿汉式单例
class HungrySingle{
	private static _instance:HungrySingle = new HungrySingle();
	//限制产生多个对象
	private constructor(){

	}
	//获得实例对象
	public static getInstance():HungrySingle{
		return this._instance;
	}
}












